
#include "common.h"
#include "resmgr.h"
#include "uimgr.h"
#include "scrollctrl.h"

class CUIComboBox;
class CUIComboPanel;

class CUIComboPanel :public CUIBase
{
public:
	friend class CUIComboBox;
	static const int BorderX=4;
	static const int BorderY=2;
	static const int ComboBoxHeight=20;
	static const int PanelBorderX=180;
	static const int PanelBorderY=100;
	static const int PanelItemSpaceX=10;
	static const int PanelItemSpaceY=10;
	static const int ItemHeaderWidth=20;
	static const int ItemHeaderHeight=20;

	int NumX;
	int NumY;
	int TotalHeight;
	int BaseX;
	int BaseY;
	int ScrollPos;
	int HoverIndex;

	CUIComboBox* ComboBox;
	ImageX_t* HeaderRes;

	CUIComboPanel();
	virtual ~CUIComboPanel();
	virtual void Draw();
	virtual int Input(UIEvent_t UIEvent,int Param1,int Param2);
};


class CUIComboBox :public CUIBase
{
public:
	friend class CUIComboPanel;
	static const int BorderX=4;
	static const int BorderY=2;
	static const int BorderButton=2;
	static const int DropBtnWidth=16;
	static const int DropBtnHeight=16;
	static const int ComboBoxHeight=20;

	static const int PanelBorderX=180;
	static const int PanelBorderY=100;
	static const int PanelItemSpaceX=10;
	static const int PanelItemSpaceY=10;
	static const int ItemHeaderWidth=20;

	std::vector<WCHAR*> ListItems;
	int SelectIndex;
	BOOL IsHover;

	ImageX_t* DropButtonRes;
	FontX_t* FontRes;

	CUIComboPanel* Panel;
	CUIVScroll* Scroll;

	int* BindPtr;

	CUIComboBox(int Width);
	virtual ~CUIComboBox();

	int GetSelect();
	void SetSelect(int Index);
	int AddItem(WCHAR* Text);
	int InsertItem(int Index,WCHAR* Text);
	int DeleteItem(int Index);
	void ClearItem();

	void BindData(int* BindPtr);

	virtual void Draw();
	virtual int Input(UIEvent_t UIEvent,int Param1,int Param2);
private:
	void UpdatePanelItemPos();
};